<%@ page import="com.baihui.taobao.AppConstants" %>
<%@ page import="com.baihui.taobao.authorize.TaoBaoSessionInfo" %>
<%@ page import="com.baihui.taobao.transition.UserCase" %>
<%@ page import="com.baihui.taobao.util.Util" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.net.URLDecoder" %>
<%@ page import="com.sun.org.apache.bcel.internal.generic.NEW" %>
<%@ page import="com.baihui.crm.DES" %>
<%--
  Created by IntelliJ IDEA.
  User: HSZM1106-0312
  Date: 11-12-25
  Time: 下午9:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<html>
<head>
    <title>数据初始化</title>
    <script type="text/javascript" src="<%=request.getContextPath()%>/jquery-1.6.2.js"></script>
    <style type="text/css">
        .container {
            margin-left: auto;
            margin-right: auto;
        }

        .header {
            background: #fdf5ce;
            text-align: left;
        }

        .content {
        }

        .content div {
            margin: 10px;
        }

        h3 {
            text-align: left;
            background-color: #dcdcdc;
            margin: 0;
            padding: 0;
        }

        table {
            width: 100%;
            margin-bottom: 0.5em;
            border: 2px #eee solid;
        }

        td {
            border-bottom: 1px solid #eee;
        }

        ul {
            list-style-type: none;
        }

        li {
            display: inline-block;
            margin: 10px;
        }

    </style>

</head>
<body>

<%
    TaoBaoSessionInfo sessionInfo = (TaoBaoSessionInfo) request.getSession().getAttribute(AppConstants.TOPSESSIONINFO);
    UserCase aCase = null;
    if (sessionInfo != null) {
        aCase = new UserCase(sessionInfo);
    }
    String secret = "125063518dd1d4eaf08b70e7e26b223afb984a66";
    String sign = Util.md5Signature(secret);

    String password = DES.encodePw("baihui888");
    password = URLEncoder.encode(password, "UTF-8");

    String url = request.getContextPath() + "/app?ACTION=association&USERID=" + session.getAttribute("USERID") + "&SIGN=" + sign + "&TBNICK=" + URLEncoder.encode(URLEncoder.encode("百会北京专卖店:伟国","utf-8"),"utf-8") + "&baihuipw="+password+"&baihuimail=baihui@126.com";
    String updateurl = request.getContextPath() + "/app?ACTION=updatePassword&USERID=" + session.getAttribute("USERID") + "&SIGN=" + sign + "&parentbaihuiId=baihuitaobaotp" +  "&parentbaihuipw="+password;
%>

<h1>这里模拟的是百会的主页</h1>
<br/>
<ul>
    <li><a href="<%=request.getContextPath()%>/app?ACTION=init&encode=utf-8">授权</a></li>
    <li><a href="<%=url%>">关联百会账号和淘宝账户</a></li>
    <li><a href="<%=updateurl%>">更改密码</a></li>
    <li>
        <a href="<%=request.getContextPath()%>/app?ACTION=importOrderData&USERID=<%=session.getAttribute("USERID")%>&SIGN=<%=sign%>&async=true">导入订单数据</a>
    </li>
    <li>
        <a href="<%=request.getContextPath()%>/app?ACTION=viewImportOrderDataProgress&USERID=<%=session.getAttribute("USERID")%>&SIGN=<%=sign%>&async=true">导入订单数据进度</a>
    </li>
    <li>
        <a href="<%=request.getContextPath()%>/app?ACTION=importProductData&USERID=<%=session.getAttribute("USERID")%>&SIGN=<%=sign%>&async=true">导入商品数据</a>
    </li>
    <li>
        <a href="<%=request.getContextPath()%>/app?ACTION=viewImportProductDataProgress&USERID=<%=session.getAttribute("USERID")%>&SIGN=<%=sign%>&async=true">查看导入商品数据进度</a>
    </li>
    <li>
        <a href="<%=request.getContextPath()%>/app?ACTION=importItemCatData&USERID=<%=session.getAttribute("USERID")%>&SIGN=<%=sign%>&async=true">导入商品分类数据</a>
    </li>
    <li>
        <a href="<%=request.getContextPath()%>/app?ACTION=viewImportItemCatData&USERID=<%=session.getAttribute("USERID")%>&SIGN=<%=sign%>&async=true">导入商品分类数据</a>
    </li>
    <li>
        <a href="<%=request.getContextPath()%>/schuduer_monitor.jsp?USERID=<%=session.getAttribute("USERID")%>&SIGN=<%=sign%>"">调度周期设置</a>
    </li>
    <li>
        <a href="<%=request.getContextPath()%>/app?ACTION=viewLog&USERID=<%=session.getAttribute("USERID")%>&SIGN=<%=sign%>&startTime=1900-01-01&endTime=2012-12-30"">查询日志</a>
    </li>
</ul>

<br/>

TBUSERID:<%=request.getParameter("TBUserID")%> <br/>
NICK:
<%
    String nick = request.getParameter("TBNick");
    if (nick != null) {
        nick =URLDecoder.decode( URLDecoder.decode(nick,"utf-8"),"utf-8");
    }

    out.println(nick);
%> <br/>
EMAIL:<%=request.getParameter("Email")%> <br/>


<script type="text/javascript">
    $(function () {
        $(".title").click(function () {
            $(this).parent().next().toggle();
        });
    });
</script>


<%
    if (sessionInfo != null) {
%>
<div class="container">
    <div class="header">淘宝数据</div>
    <div class="content">
        <div class="app">
            <h3><a href="#" class="title">应用数据(点击)</a></h3>

            <div class="example" style="display: none;">
                <table style="border: 1px solid;">
                    <tr style="border: 1px solid">
                        <td width="50%">参数名</td>
                        <td width="50%">参数值</td>
                    </tr>
                    <tr>
                        <td>AppKey(应用Key)</td>
                        <td><%=sessionInfo.getAppKey()%>
                        </td>
                    </tr>
                    <tr>
                        <td>topSession(session信息)</td>
                        <td><%=sessionInfo.getTopSession()%>
                        </td>
                    </tr>
                    <tr>
                        <td>appSecret(应用密钥)</td>
                        <td><%=sessionInfo.getAppSecret()%>
                        </td>
                    </tr>
                    <tr>
                        <td>ts(当前时间戳)</td>
                        <td><%=sessionInfo.getTopParameter().getTs()%>
                        </td>
                    </tr>
                    <tr>
                        <td>iframe(输出是否在IFRAME中)</td>
                        <td><%=sessionInfo.getTopParameter().getIframe()%>
                        </td>
                    </tr>
                    <tr>
                        <td>visitor_id(当前用户ID)</td>
                        <td><%=sessionInfo.getTopParameter().getVisitor_id()%>
                        </td>
                    </tr>
                    <tr>
                        <td>visitor_nick(当前用户昵称)</td>
                        <td><%=sessionInfo.getTopParameter().getVisitor_nick()%>
                        </td>
                    </tr>
                    <tr>
                        <td>visitor_role(当前用户角色)</td>
                        <td><%=sessionInfo.getTopParameter().getVisitor_role()%>
                        </td>
                    </tr>
                    <tr>
                        <td>expires_in(Session_key 失效时间)</td>
                        <td><%=sessionInfo.getTopParameter().getExpires_in()%>
                        </td>
                    </tr>
                    <tr>
                        <td>re_expires_in(refresh token 失效时间)</td>
                        <td><%=sessionInfo.getTopParameter().getRe_expires_in()%>
                        </td>
                    </tr>
                    <tr>
                        <td>sub_visitor_id(子帐号ID)</td>
                        <td><%=sessionInfo.getTopParameter().getSub_visitor_id()%>
                        </td>
                    </tr>
                    <tr>
                        <td>sub_visitor_nick(子帐号nick)</td>
                        <td><%=sessionInfo.getTopParameter().getSub_visitor_nick()%>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</div>
<%
    }
%>

<br/>


</body>
</html>